﻿using System.ServiceModel.Syndication;
using NCMIS.ServiceModel.Syndication;
using System.Collections.Generic;
using System;

namespace NCMIS.Client
{
    /// <summary>
    /// Class whose sole purpose is to act as an interface between the caller (e.g. CmisDirectory) and the callee (e.g CmisWebRequest).
    /// </summary>
    public class ClientCmisQuery
    {
        /// <summary>
        /// Constructs a new CMIS query object and calls methods to construct and execute the search query.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="searchParams"></param>
        /// <returns></returns>
        public static SyndicationFeed performQuery(CmisWebRequest request, Dictionary<string, Object> searchParams)
        {
            // Construct CMIS query
            CmisQuery searchQuery = new CmisQuery();
            searchQuery.buildSelectStatement(searchParams);

            // Perform search
            SyndicationFeed searchResult = request.InvokeCmisQuery(CmisQuery.queryURI, searchQuery);

            return searchResult;
        }
    }
}